//package org.jeecg.modules.aliyun.entity.service.impl;
//
//import cn.hutool.core.util.RandomUtil;
//import com.aliyun.core.utils.StringUtils;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import org.jeecg.modules.acmd.service.IAcmdService;
//import org.jeecg.modules.aliyun.entity.run.SpringContextUtil;
//import org.jeecg.modules.oss.entity.OssFile;
//import org.jeecg.modules.oss.mapper.OssFileMapper;
//import org.jeecg.modules.phone.entity.*;
//import org.jeecg.modules.phone.enums.EntityEnums;
//import org.jeecg.modules.phone.enums.ResourcesEnums;
//import org.jeecg.modules.phone.enums.TaskEnums;
//import org.jeecg.modules.phone.mapper.*;
//import org.jeecg.modules.system.util.HttpDownloadUtil;
//import org.jeecg.modules.system.util.ImageUtils;
//import org.jeecg.modules.system.util.PhotoDigest;
//import org.jetbrains.annotations.NotNull;
//
//import java.util.Date;
//import java.util.List;
//
//import static org.jeecg.modules.system.util.PhotoDigest.getData;
//
//public class PhoneEntityTaskImplements implements Runnable{
//    private PhoneEntityTask phoneEntityTask;
//    private PhoneEntity phoneEntity;
//    private PhoneAccountLogMapper phoneAccountLogMapper;
//
//
//    private PhoneEntityCmdMapper phoneEntityCmdMapper;
//
//    public void run() {
//        //3):在run方法中编写需要执行的操作
//        System.out.println(phoneEntityTask.getId());
//        System.out.println(Thread.currentThread().getName());
//        try {
//            Thread.sleep(6000);
//            System.out.println("run" + Thread.currentThread().getName());
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
////        if(1>0){
////            return;
////        }
//
//
//        /*识别任务并开始，这里是小任务。*/
//        IAcmdService acmdService = SpringContextUtil.getBean(IAcmdService.class);
//        PhoneEntityMapper phoneEntityMapper = SpringContextUtil.getBean(PhoneEntityMapper.class);
//        this.phoneEntity = phoneEntityMapper.selectById(phoneEntityTask.getEntityId());
//        PhoneAccountLogMapper  phoneAccountLogMapper = SpringContextUtil.getBean(PhoneAccountLogMapper.class);
//        this.phoneAccountLogMapper = phoneAccountLogMapper;
//
//        PhoneEntityCmdMapper  phoneEntityCmdMapper = SpringContextUtil.getBean(PhoneEntityCmdMapper.class);
//        this.phoneEntityCmdMapper = phoneEntityCmdMapper;
//
//        /*母号
//        挂链接
//        任务*/
//        //打开抖推猫主页
//        if(phoneEntityTask.getTaskChildrenId().equals("asdfa434")){ asdfa434(acmdService);  }
//        //搜索关键词游戏
//        if(phoneEntityTask.getTaskChildrenId().equals("asdfa435")){ asdfa435(acmdService);  }
//        //点击扫码推广下载
//        if(phoneEntityTask.getTaskChildrenId().equals("asdfa436")){ asdfa436(acmdService);  }
//        //打开抖音扫推广码
//        if(phoneEntityTask.getTaskChildrenId().equals("asdfa437")){ asdfa437(acmdService);  }
//        //在小程序发布同款
//        if(phoneEntityTask.getTaskChildrenId().equals("asdfa438")){
//            asdfa438(acmdService);
//            /*最后一个步骤的时候，更新资源状态*/
//            updateResourceStatus();
//        }
//
//
//
//
//        /*母号
//        头像壁纸
//        任务*/
//        //抖音发布壁纸1
//        if(phoneEntityTask.getTaskChildrenId().equals("asdfa441")){ asdfa441(acmdService);  }
//        //抖推猫壁纸中心2
//        if(phoneEntityTask.getTaskChildrenId().equals("asdfa442")){ asdfa442(acmdService);  }
//        //设置分类并确认上传 3
//        if(phoneEntityTask.getTaskChildrenId().equals("asdfa443")){
//            asdfa443(acmdService);
//            /*最后一个步骤的时候，更新资源状态*/
//            updateResourceStatus();
//        }
//
//        /*子号
//        点击小程序链接
//        任务*/
//        //在抖音识别连接1
//        if(phoneEntityTask.getTaskChildrenId().equals("asdfa451")){ asdfa451(acmdService);  }
//        //在小程序看完广告2
//        if(phoneEntityTask.getTaskChildrenId().equals("asdfa452")){
//            asdfa452(acmdService);
//            /*最后一个步骤的时候，更新资源状态*/
//            updateResourceStatus();
//        }
//
//        /*子号
//        下载信息流视频图片
//        任务*/
//        //在抖音搜花海图册1
//        if(phoneEntityTask.getTaskChildrenId().equals("asdfa461")){
//            if(!StringUtils.isEmpty(phoneEntityTask.getTag()) && phoneEntityTask.getTag().equals("onlyCheck")){
//                checkPointJob("a4",0  );
//            }else{
//                asdfa461(acmdService);
//            }
//
//        }
//        //输口令看广告下载2
//        if(phoneEntityTask.getTaskChildrenId().equals("asdfa462")){
//            asdfa462(acmdService);
//            /*最后一个步骤的时候，更新资源状态*/
//            updateResourceStatus();
//        }
//
//
////        updateThis2CompletedorFail(TaskEnums.TaskStatus.COMPLETED.getName());
//    }
//
//    private void updateThis2CompletedorFail(String taskStatus) {
//        PhoneEntityTaskMapper phoneEntityTaskMapper = SpringContextUtil.getBean(PhoneEntityTaskMapper.class);
//        phoneEntityTask.setTaskStatus(taskStatus);
//        phoneEntityTaskMapper.updateById(phoneEntityTask);
//
//        if(taskStatus.equals(TaskEnums.TaskStatus.FAIL.getName())){
//            PhoneEntityMapper phoneEntityMapper = SpringContextUtil.getBean(PhoneEntityMapper.class);
//            PhoneEntity phoneEntity = phoneEntityMapper.selectById(phoneEntityTask.getEntityId());
//            phoneEntity.setEntityStatus(EntityEnums.EntityStatus.WARN.getName());
//            phoneEntityMapper.updateById(phoneEntity);
//            PhoneEntityCmdMapper phoneEntityCmdMapper = SpringContextUtil.getBean(PhoneEntityCmdMapper.class);
//            phoneEntityCmdMapper.update(new PhoneEntityCmd().setCmdStatus("0"),new QueryWrapper<PhoneEntityCmd>()
//                    .lambda().eq(PhoneEntityCmd::getEntityId,phoneEntity.getId())
//            );
//            System.out.println("----------更新cmd=0");
//        }
//
//    }
//
//
//    public void setPhoneEntityTask(PhoneEntityTask phoneEntityTask,PhoneEntityTaskMapper phoneEntityTaskMapper){
//        this.phoneEntityTask = phoneEntityTask;
//        /*也可传进来*/
////        this.phoneEntityTaskMapper = phoneEntityTaskMapper;
//    }
//
//    private void updateResourceStatus() {
//        System.out.println("更新手机状态为在线，表示已经完成本次任务。");
////        PhoneEntityTaskRsourceMapper phoneEntityTaskRsourceMapper = SpringContextUtil.getBean(PhoneEntityTaskRsourceMapper.class);
////        PhoneEntityTaskRsource phoneEntityTaskRsource
////                = phoneEntityTaskRsourceMapper.selectById(phoneEntityTask.getResourceId());
////
////        phoneEntityTaskRsource.setResourceStatus(ResourcesEnums.ResourcesStatus.STOP.getName());
////        phoneEntityTaskRsourceMapper.updateById(phoneEntityTaskRsource);
//
//
//        PhoneEntityMapper phoneEntityMapper = SpringContextUtil.getBean(PhoneEntityMapper.class);
//        phoneEntityMapper.update(
//                new PhoneEntity().setEntityStatus(EntityEnums.EntityStatus.ONLINE.getName()),
//                new QueryWrapper<PhoneEntity>().lambda().eq(PhoneEntity::getId,phoneEntityTask.getEntityId())
//                );
//
//    }
//    private PhoneEntityTaskRsource getResourceStatus() {
//
//        /*获取当前任务的资源任务ID，即parentID*/
//        PhoneTaskChildrenMapper phoneTaskChildrenMapper = SpringContextUtil.getBean(PhoneTaskChildrenMapper.class);
//        PhoneTaskChildren phoneTaskChildren = phoneTaskChildrenMapper.selectById(phoneEntityTask.getTaskChildrenId());
////        phoneTaskChildren.getParentTaskId()
//
//        /*获取当前资源实例 并更新状态，参数 taskId ,entityID */
//        PhoneEntityTaskRsourceMapper phoneEntityTaskRsourceMapper = SpringContextUtil.getBean(PhoneEntityTaskRsourceMapper.class);
//        PhoneEntityTaskRsource phoneEntityTaskRsource = phoneEntityTaskRsourceMapper.selectOne(
//                new QueryWrapper<PhoneEntityTaskRsource>().lambda()
//                        .eq(PhoneEntityTaskRsource::getEntityId,phoneEntityTask.getEntityId())
//                        .eq(PhoneEntityTaskRsource::getTaskId,phoneTaskChildren.getParentTaskId())
//                        .eq(PhoneEntityTaskRsource::getResourceStatus, ResourcesEnums.ResourcesStatus.ENABLED.getName())
//        );
//
//        return phoneEntityTaskRsource;
//
//    }
//    private void sleepSecond(Integer n) {
//        sleepSecond(n,"");
//    }
//    private void sleepSecond(Integer n,String msg) {
//        try {
//            System.out.println(msg);
//            Thread.sleep(1000*n);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
//    }
//    private void cmdBy4G(String cmdStr) {
//
//        PhoneEntityMapper phoneEntityMapper =  SpringContextUtil.getBean(PhoneEntityMapper.class);
//        PhoneEntity phoneEntity1 = phoneEntityMapper.selectById(phoneEntity.getId());
//        if(!phoneEntity1.getEntityStatus().equals(EntityEnums.EntityStatus.RUNNING.getName())){
//            return ;   /*执行中才给继续执行。*/
//        }
//
//        PhoneEntityCmd phoneEntityCmd = new PhoneEntityCmd().setEntityId(phoneEntity.getId())
//                .setCmdStatus("1").setCmdStr(cmdStr);
//        phoneEntityCmdMapper.insert(phoneEntityCmd);
//        System.out.println("插入数据库：" + cmdStr);
//        System.out.println(phoneEntityCmd.getId());
//
//        int count = 1;
//        while (count < 12) {
//            sleepSecond(1,"命令执行中-----"+count+++"-----------" + cmdStr);
//            PhoneEntityCmd phoneEntityCmd1 = phoneEntityCmdMapper.selectById(phoneEntityCmd.getId());
//            if(phoneEntityCmd1.getCmdStatus().equals("0")){
//                count = 1000 ;
//                System.out.println("------执行完毕----------：" + cmdStr);
//            }
//            phoneEntityCmdMapper.updateById(new PhoneEntityCmd().setId(phoneEntityCmd1.getId()).setUpdateTime(new Date()));
//        }
//        if(count<1000){
//            /*超时了，需要定义为异常*/
//            updateThis2CompletedorFail(TaskEnums.TaskStatus.FAIL.getName());
//        }
//
//
//    }
//    private void saveScreen(String fileName) {
//        cmdBy4G("screencap -p /sdcard/" + fileName);
//        cmdBy4G("smallSdcardPng" + fileName);
//        cmdBy4G("uploadFileToServer" + fileName);
//    }
//
//
//    /*母号1的5个步骤*/
//    private void asdfa434(IAcmdService acmdService) {
//
//////        acmdService.doCmd(    "adb kill-server");
//////        acmdService.doCmd(    "adb start-server");
//////        String adb_if_config
////////				 = acmdService.doCmd("adb shell ifconfig wlan0 |findstr addr");
//////                = acmdService.doCmd("adb shell ifconfig eth0 |findstr addr");
//////        acmdService.doCmd("adb  tcpip 5555");
//////        acmdService.doCmd("adb shell am start  com.doutui.bozhong/io.dcloud.PandoraEntryActivity");
////
////        acmdService.doCmd("adb  connect " + phoneEntity.getEntityIp() +":5555");
////
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am force-stop com.doutui.bozhong"); /*关闭抖猫*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input keyevent  3"); /*按Home*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input keyevent  3"); /*按Home*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 171 1374"); /*打开抖音猫*/
////
//
//
//        cmdBy4G("input keyevent  3");
//        cmdBy4G("input tap 151 1340");  //点击抖猫图标，放到主屏第一个位置
//
//        String fileName = "screen_" + RandomUtil.randomString(8) + ".png";
//        saveScreen(fileName);
//
//        phoneAccountLogMapper.insert(
//                new PhoneAccountLog()
//                        .setAccountId(phoneEntity.getId())
//                        .setLogMsg("打开抖推猫主页(" + fileName + ")") /*1*/
//        );
//      }
//
//    private void asdfa435(IAcmdService acmdService) {
//
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 808 304"); /*打开抖音猫搜索按钮*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell ime set com.android.adbkeyboard/.AdbIME"); /*打开抖音猫设置adb input*/
//////        Switch back to original virtual keyboard: (swype in my case...)
//////        adb shell ime set com.nuance.swype.dtc/com.nuance.swype.input.IME
//////        Check your available virtual keyboards:
//////        adb shell ime list -a      sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 187 314"); /*打开抖音猫搜索框*/
////
////
//////        # am broadcast -a clipper.set -e text "this can be pasted now"
//////# am broadcast -a clipper.get
////
////
////        String searchKey = "你是什么脸型,你是什么脸型,你是什么脸型".split(",")[ RandomUtil.randomInt(0,2)];
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am broadcast -a ADB_INPUT_TEXT --es msg '"+searchKey+"'");  /*打开抖音猫输入关键字*/
////
////        sleepSecond(2);
//////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 187 314"); /*打开抖音猫搜索框*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 909 317"); /*点击搜索或回车*/
//
//
//        cmdBy4G("input tap 434 286"); //点击搜索框434 286
//        cmdBy4G("ime set com.android.adbkeyboard/.AdbIME");
//        cmdBy4G("input tap 434 307");//点击专题搜索框434 307
//
//        String searchKey = "你是什么脸型,你是什么脸型,你是什么脸型".split(",")[ RandomUtil.randomInt(0,2)];
//        cmdBy4G("am broadcast -a ADB_INPUT_TEXT --es msg '"+searchKey+"'");
////        am broadcast -a ADB_INPUT_TEXT --es msg '你是什么脸型'
//        cmdBy4G("input tap 969 299"); //搜索确定969 299
//
//        String fileName = "screen_" + RandomUtil.randomString(8) + ".png";
//        saveScreen(fileName);
//
//        phoneAccountLogMapper.insert(
//                new PhoneAccountLog()
//                        .setAccountId(phoneEntity.getId())
//                        .setLogMsg("搜索关键词游戏(" + fileName + ")") /*1*/
//        );
//    }
//
//    private void asdfa436(IAcmdService acmdService) {
//
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 887 510"); /*点击二维码*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell screencap -p /sdcard/screen_"+ phoneEntityTask.getId() +".png"); /*截图*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am force-stop com.doutui.bozhong"); /*关闭抖猫*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard/screen_"+ phoneEntityTask.getId() +".png");
//
//
//        cmdBy4G("input tap 957 499"); //点击扫码推广957 499
//        String fileName = "screen_" + RandomUtil.randomString(8) + ".png";
//        saveScreen(fileName);
//        phoneAccountLogMapper.insert(
//                new PhoneAccountLog()
//                        .setAccountId(phoneEntity.getId())
//                        .setLogMsg("扫码推广的二维码(" + fileName + ")") /*1*/
//        );
//
//        cmdBy4G("am force-stop com.doutui.bozhong");
////        cmdBy4G("am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard/screen_"+ phoneEntityTask.getId() +".png");
//
//    }
//
//    private void asdfa437(IAcmdService acmdService) {
//
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am force-stop com.ss.android.ugc.aweme"); /*关闭抖音*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am start com.ss.android.ugc.aweme/.main.MainActivity"); /*打开抖音*/
////
////        sleepSecond(10);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 1001 165"); /*点搜索*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 862 168"); /*点扫*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 860 1772"); /*点相册*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 141 501"); /*点第一图片*/
////        sleepSecond(22);
//
//
//        cmdBy4G("am force-stop com.ss.android.ugc.aweme");
//        cmdBy4G("am start com.ss.android.ugc.aweme/.main.MainActivity");
//        sleepSecond(200,"打开抖音很慢");
//        cmdBy4G("input tap 83 137"); //抖音扫一扫83 137
//
//        cmdBy4G("input tap 832 1499");////相册832 1499
//        cmdBy4G("input tap 134 487");//相册第一张134 487
//
////        这里抖音授权超级忙
//        sleepSecond(200,"抖音授权");
//        cmdBy4G("input tap 73 1559");//同意授权73 1559
//        cmdBy4G("input tap 798 1686"); //同意按钮798 1686
//
//        phoneAccountLogMapper.insert(
//                new PhoneAccountLog()
//                        .setAccountId(phoneEntity.getId())
//                        .setLogMsg("打开抖音扫推广码") /*4*/
//        );
//    }
//
//    private void asdfa438(IAcmdService acmdService) {
//
////        sleepSecond(5);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 1009 355"); /*点拍视频+*/
////        sleepSecond(5);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 857 1983"); /*点相册*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 545 308"); /*点视频*/
////        sleepSecond(2);
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 127 474"); /*点视频文件*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 67 2235"); /*勾*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 995 2216"); /*点确认*/
////        sleepSecond(2);
////
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 542 2214"); /*点下一步*/
////        sleepSecond(2);
////
//////        获取文字，先下载文字，然后读行写入。
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell ime set com.android.adbkeyboard/.AdbIME"); /*打开抖音猫设置adb input*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 184 349"); /*点添加描述*/
////
////
////        String searchKey = "你是什么脸型,你是什么脸型,你是什么脸型".split(",")[ RandomUtil.randomInt(0,2)];
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am broadcast -a ADB_INPUT_TEXT --es msg '"+searchKey+"'");  /*打开抖音猫输入关键字*/
////
////
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 491 1533"); /*点空白发布*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 819 2227"); /*点发布*/
////
//
//
//        cmdBy4G("input tap 992 362"); //拍视频992 362
//        sleepSecond(5);
//        cmdBy4G("input tap 851 1551"); ////点相册851 1551
//        cmdBy4G("input tap 136 493"); //////点第一张136 493
//        cmdBy4G("input tap 906 1725"); ////点确定906 1725
//        cmdBy4G("input tap 545 1715"); ////下一步545 1715
//
//        //获取文本文件，读取内容，粘贴进来。
//
//        cmdBy4G("input tap 185 309"); //点击文本区域185 309
//        cmdBy4G("shell ime set com.android.adbkeyboard/.AdbIME"); ////下一步545 1715
//        cmdBy4G("shell am broadcast -a ADB_INPUT_TEXT --es msg '这个是一个很牛的作品'"); ////下一步545 1715
//
//
//        cmdBy4G("input tap 818 1715"); //发布818 1715
//
//        cmdBy4G("input tap 990 145");  //关闭作品990 145
//        cmdBy4G("input keyevent 4");  //返回
//        cmdBy4G("input tap 967 1727");    //我967 1727
//        cmdBy4G("input swipe 300 800 300 80");    //我967 1727上滑
//        cmdBy4G("input tap 181 725");   //第一作品181 725  //点点点982 1372
//        cmdBy4G("input tap 982 1372");      //点点点982 1372
//        cmdBy4G("input tap 982 1372");      //点点点982 1372
//
//
//        phoneAccountLogMapper.insert(
//                new PhoneAccountLog()
//                        .setAccountId(phoneEntity.getId())
//                        .setLogMsg("在小程序发布同款") /*5*/
//        );
//    }
//
//
//    /*母号2的3个步骤*/
//
//    private void asdfa441(IAcmdService acmdService) {
////        PhoneEntityTaskRsource phoneEntityTaskRsource = getResourceStatus();
////        if( phoneEntityTaskRsource!=null && (!StringUtils.isEmpty(phoneEntityTaskRsource.getImg() ))){
////            String[] split = phoneEntityTaskRsource.getImg().toString().split(",");
////            for (int i = 0; i < split.length; i++) {
////                String url = split[i];
////                String temp[] = url.split("/"); /**split里面必须是正则表达式，"\\"的作用是对字符串转义*/
////                String fileName = temp[temp.length-1];
////                acmdService.doPower("PowerShell -Command  \"wget -O d:\\adb\\" +
////                        phoneEntity.getEntityIp().replace(".","_") + ""+ fileName+"  " +  url +" \" "  );
////                acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                        " push d:\\adb\\" +    phoneEntity.getEntityIp().replace(".","_") +  ""+ fileName+"  /sdcard/"); /*点底部+*/
////                acmdService.doPower("del d:\\adb\\" +
////                        phoneEntity.getEntityIp().replace(".","_") + ""+ fileName+"    "  );
////            }
////        }
////
//////        https://ylphone.oss-cn-hangzhou.aliyuncs.com/upload/admin/192_168_3_118/screenshot20220830222542.png,https://ylphone.oss-cn-hangzhou.aliyuncs.com/upload/admin/192_168_3_118/screenshot20220830220517.png
////
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am force-stop com.ss.android.ugc.aweme"); /*打开抖音*/
////        sleepSecond(5);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am start com.ss.android.ugc.aweme/.main.MainActivity"); /*打开抖音*/
////        sleepSecond(15);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 472 2168"); /*点底部+*/
////        sleepSecond(4);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 789 1932"); /*点相册*/
////        sleepSecond(4);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 900 300"); /*点相册*/
////       sleepSecond(4);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 100 510"); /*点作品*/
////        sleepSecond(4);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 746 2165"); /*下一步*/
////        sleepSecond(4);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 746 2165"); /*发布*/
////        sleepSecond(4);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 662 1441"); /*继续发布*/
////
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am force-stop com.ss.android.ugc.aweme"); /*关闭抖音*/
//
////        adb shell input keyevent 187 切换应用
//
//
//        //获取图片 默认这个任务就是放一张图片
//
//
//        PhoneEntityTaskRsourceMapper phoneEntityTaskRsourceMapper = SpringContextUtil.getBean(PhoneEntityTaskRsourceMapper.class);
//        PhoneEntityTaskRsource phoneEntityTaskRsource
//                =  phoneEntityTaskRsourceMapper.selectOne(
//                new QueryWrapper<PhoneEntityTaskRsource>().lambda()
//                        .eq(PhoneEntityTaskRsource::getEntityId,phoneEntity.getId())
//                        .eq(PhoneEntityTaskRsource::getTaskId,"a2").last("limit 1")
//        );
//        if(StringUtils.isEmpty(phoneEntityTaskRsource.getImg().toString())){
//            System.out.println("未找到本任务的图片资源。清上传一张图片。");
//            return  ;
//        }
//
//        HttpDownloadUtil.download(phoneEntityTaskRsource.getImg().toString(),"/sdcard/zhiYuan.png");
//
//        //
//
//
////        点击抖音发布上传作品
//        cmdBy4G("am start com.ss.android.ugc.aweme/.main.MainActivity"); // 打开抖音
//        sleepSecond(150);
//        cmdBy4G("input tap 536 1723"); // 点底下+536 1723
//        sleepSecond(10);  // 调取摄像头有点慢
//        cmdBy4G("input tap 871 1540"); //点相册871 1540
////        这里会显示上传的视频或图片。这里测试图片
//        cmdBy4G("input tap 161 524"); //点相册//第一个161 524
//
//        cmdBy4G("input tap 802 1715"); ////下一步802 1715
//
//        sleepSecond(10);  // 下一步有点慢
//
////        这里可以加文字描述
//        cmdBy4G("input tap 875 1719"); //点//发布875 1719
//        sleepSecond(3);  // 下一步有点慢
//        cmdBy4G("am force-stop com.ss.android.ugc.aweme"); //点//发布875 1719
//
//
//
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 536 1723"); /*点底部//点底下+536 1723+*/
////        sleepSecond(4);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 789 1932"); /*点相册*/
////        sleepSecond(4);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 900 300"); /*点相册*/
////       sleepSecond(4);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 100 510"); /*点作品*/
////        sleepSecond(4);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 746 2165"); /*下一步*/
////        sleepSecond(4);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 746 2165"); /*发布*/
////        sleepSecond(4);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 662 1441"); /*继续发布*/
////
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am force-stop com.ss.android.ugc.aweme"); /*关闭抖音*/
//
//
//        phoneAccountLogMapper.insert(
//                new PhoneAccountLog()
//                        .setAccountId(phoneEntity.getId())
//                        .setLogMsg("抖音发布壁纸") /*5*/
//        );
//    }
//
//    private void asdfa442(IAcmdService acmdService) {
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am force-stop com.doutui.bozhong"); /*关闭抖音*/
////        sleepSecond(5);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input keyevent  3"); /*按Home*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input keyevent  3"); /*按Home*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 171 1374"); /*打开抖音猫*/
////        sleepSecond(5);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 876 2178"); /*点我的+*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input swipe 300 800 300 80"); /*向上滑动*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input swipe 300 800 300 80"); /*向上滑动*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 597 1417"); /*点创作者中心*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 325 671"); /*点壁纸中心*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 152 1388"); /*上传素材*/
//////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 746 2165"); /*分类*/
//////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 662 1441"); /*标签默认就有*/
//
//        cmdBy4G("input keyevent  3"); // 按Home
//        cmdBy4G("input keyevent  3"); // 按Home
//        cmdBy4G("input tap 144 1340"); // 打开抖音猫//开抖猫144 1340
//        sleepSecond(3);
//        cmdBy4G("input tap 945 1717"); ////点抖猫我的945 1717
//        sleepSecond(30);
//        cmdBy4G("input swipe 300 800 300 80"); //  向上滑动
//        cmdBy4G("input swipe 300 800 300 80"); //  向上滑动
//        cmdBy4G("input swipe 300 800 300 80"); //  向上滑动
//        cmdBy4G("input tap 673 971"); ////创造者中心673 971
//        sleepSecond(5);
//        cmdBy4G("input tap 536 1723"); ////壁纸465 643
//        sleepSecond(5);
//
////        这里需要设置口令 停下了。
////        cmdBy4G("input tap 536 1723"); //
////        cmdBy4G("input tap 536 1723"); //
////        sleepSecond(10);  // 调取摄像头有点慢
////        cmdBy4G("input tap 871 1540"); //
//////        这里会显示上传的视频或图片。这里测试图片
////        cmdBy4G("input tap 161 524"); //点相册//第一个161 524
////
////        cmdBy4G("input tap 802 1715"); ////下一步802 1715
////
////        sleepSecond(10);  // 下一步有点慢
////
//////        这里可以加文字描述
////        cmdBy4G("input tap 875 1719"); //点//发布875 1719
////        sleepSecond(3);  // 下一步有点慢
////        cmdBy4G("am force-stop com.ss.android.ugc.aweme"); //点//发布875 1719
//
//        phoneAccountLogMapper.insert(
//                new PhoneAccountLog()
//                        .setAccountId(phoneEntity.getId())
//                        .setLogMsg("抖推猫壁纸中心") /*5*/
//        );
//    }
//
//    private void asdfa443(IAcmdService acmdService) {
//
//        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 130 1528"); /*点上传图片*/
//        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 113 407"); /*选1+*/
//        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 488 407"); /*选2*/
//        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 890 169"); /*点完成*/
//        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input swipe 300 800 300 80"); /*向上滑动*/
//        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input swipe 300 800 300 80"); /*向上滑动*/
//        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 507 2141"); /*发布*/
//
//
//
//        phoneAccountLogMapper.insert(
//                new PhoneAccountLog()
//                        .setAccountId(phoneEntity.getId())
//                        .setLogMsg("设置分类并确认上传") /*5*/
//        );
//    }
//
//
//
//
//
//    /*子号1的2个步骤*/
//    private void asdfa451(IAcmdService acmdService) {
//
//        //修改复制粘贴为保存图片。
////        下载图片到本机。用抖音扫
//
//
//    }
//
//    private void asdfa452(IAcmdService acmdService) {
//
//
//
//    }
//
//
//
//    /*子号2的2个步骤*/
//    private void asdfa461(IAcmdService acmdService) {
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am force-stop com.ss.android.ugc.aweme"); /*关闭抖音*/
////        sleepSecond(5);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " +
////                "shell am start com.ss.android.ugc.aweme/.main.MainActivity"); /*打开抖音*/
////        sleepSecond(15);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 1009 162"); /*抖音搜索*/
////
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " + "shell ime set com.android.adbkeyboard/.AdbIME"); /*打开抖音猫设置adb input*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap 428 165"); /*标签默认就有*/
////        String searchKey = "花海图册小程序" ;
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 " + "shell am broadcast -a ADB_INPUT_TEXT --es msg '"+searchKey+"'");  /*打开抖音猫输入关键字*/
////
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap  990 173"); /*抖音搜索*/
//
//        cmdBy4G("am force-stop com.ss.android.ugc.aweme");
//        sleepSecond(5);
//        cmdBy4G("am start com.ss.android.ugc.aweme/.main.MainActivity");
//        sleepSecond(50);
//        cmdBy4G("input tap 306 1667"); //点等待306 1667
//        cmdBy4G("input tap 108 1727"); //点首页108 1727
//        cmdBy4G("input tap 1009 162");
//        cmdBy4G("ime set com.android.adbkeyboard/.AdbIME");
//        cmdBy4G("input tap 428 165");
//        cmdBy4G("am broadcast -a ADB_INPUT_TEXT --es msg '花海图册小程序'");
//        cmdBy4G("input tap  982 139"); //点搜索982 139
//
//
//
//        //检查是否有对比图，如果没有就继续。如果有就停了。
//        checkPointJob("a4",0  );
//
//        phoneAccountLogMapper.insert(
//                new PhoneAccountLog()
//                        .setAccountId(phoneEntity.getId())
//                        .setLogMsg("在抖音搜花海图册") /* 5 */
//        );
//    }
//
//    private void checkPointJob(String childTaskId, Integer seq  ) {
//        System.out.println("---------------------开始检查断点Job---------");
//        String ScreenCapFile = "screen_" + RandomUtil.randomString(8) + ".png";
//        saveScreen(ScreenCapFile);
//
//        /*获取截图*/
//        String ScreenCapFile1 = getOssFiles(ScreenCapFile);
//        /*获取对比图原图*/
//        PhoneTaskMapper phoneTaskMapper = SpringContextUtil.getBean(PhoneTaskMapper.class);
//        PhoneTask phoneTask = phoneTaskMapper.selectOne(new QueryWrapper<PhoneTask>().lambda().eq(PhoneTask::getId, childTaskId));
//        String[] split = phoneTask.getParameter1().toString().split(",");
//        String ContrastImg2 = "";
//        if(split.length>0){
//            ContrastImg2 = split[seq];
//        }
//
//        float percent = 0 ;
//        System.out.println("ScreenCapFile1");
//        System.out.println(ScreenCapFile1);
//        System.out.println("ContrastImg2");
//        System.out.println(ContrastImg2);
//        if(!StringUtils.isEmpty(ScreenCapFile1) && !StringUtils.isEmpty(ContrastImg2)  ){
//            String rnd1 = "D://"+RandomUtil.randomString(6)+".jpg" ;
//            String rnd2 = "D://"+RandomUtil.randomString(6)+".jpg" ;
//            ImageUtils.downLoadImg("https://ylphone.oss-cn-hangzhou.aliyuncs.com/upload/2022/09/fniaqc5re94pldq.png",rnd1);
//            ImageUtils.downLoadImg("https://ylphone.oss-cn-hangzhou.aliyuncs.com/upload/2022/09/ftbnopmjpza5rjx.png",rnd2);
//            percent = PhotoDigest.compare(getData(rnd1),getData(rnd2));
//        }
//        System.out.println(percent);
//        if(percent > 80){
//            updateThis2CompletedorFail(TaskEnums.TaskStatus.COMPLETED.getName());
//        }else{
//            updateThis2CompletedorFail(TaskEnums.TaskStatus.FAIL.getName());
//
//        }
//
//    }
//
//    @NotNull
//    private   String getOssFiles(String ScreenCapFile) {
//        String returnFileName = "";
//        OssFileMapper ossFileMapper = SpringContextUtil.getBean(OssFileMapper.class);
//
//        int count = 1;
//        while (count < 11) {
//            System.out.println("Count is: "+ count); count++;
//            sleepSecond(3,"检查截图中----------------");
//            List<OssFile> list = ossFileMapper.selectList(new QueryWrapper<OssFile>().lambda()
//                    .like(OssFile::getFileName, ScreenCapFile)
//                    .orderByDesc(OssFile::getCreateTime).last("limit 1")
//            );
//            if(list.size()>0){
//                count = 100 ;
//                returnFileName = list.get(0).getUrl();
//            }
//        }
//        return returnFileName;
//    }
//
//    private void asdfa462(IAcmdService acmdService) {
////        sleepSecond(5,"进入");
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap  936 682"); /*进入*/
////        sleepSecond(15,"抖音搜索号码");
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap  179 766"); /*抖音搜索号码*/
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap  179 766"); /*抖音搜索号码*/
////        sleepSecond(2,"抖音搜索");
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input text 7777"); /*抖音搜索*/
////        sleepSecond(2,"抖音搜索");
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap  963 764"); /*抖音搜索*/
////        sleepSecond(2,"第一个视频");
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap  181 1205"); /*第一个视频*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap  960 1682"); /*下载*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap  331 1436"); /*下载有什*/
////        sleepSecond(40);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap  995 159"); /*关闭*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap  960 1682"); /*下载*/
////        sleepSecond(2);
////        acmdService.doCmd("adb -s  " + phoneEntity.getEntityIp() +":5555 shell input tap  960 1682"); /*下载*/
//
//        cmdBy4G("input tap  910 555"); //点进入910 555
//        sleepSecond(135,"进入小程序");
//        cmdBy4G("input tap  244 727"); //点口令342 807  //点口令244 727
//        cmdBy4G("input tap  244 727"); //点口令342 807  //点口令244 727
//
//
//        PhoneEntityTaskRsourceMapper phoneEntityTaskRsourceMapper = SpringContextUtil.getBean(PhoneEntityTaskRsourceMapper.class);
//        PhoneEntityTaskRsource phoneEntityTaskRsource
//                =  phoneEntityTaskRsourceMapper.selectOne(
//				new QueryWrapper<PhoneEntityTaskRsource>().lambda()
//						.eq(PhoneEntityTaskRsource::getEntityId,phoneEntity.getId())
//						.eq(PhoneEntityTaskRsource::getTaskId,"a4").last("limit 1")
//		);
//        String code = HttpDownloadUtil.readRemoteTxt(phoneEntityTaskRsource.getTxt().toString());
//        cmdBy4G("input text " + code );
//        cmdBy4G("input tap  941 729");//点搜索口令945 797  //点搜索口令941 729
//        sleepSecond(10,"进入小程序");
//        cmdBy4G("input tap  169 938"); //第一作品 169 938
//        sleepSecond(10,"进入第一个作品");
//
//        cmdBy4G("input tap  957 1204"); //点下载957 1204
//        cmdBy4G("input tap  340 1190"); //点保存高清 340 1190
//
//        sleepSecond(60,"看广告");
//        cmdBy4G("input tap  975 102");  //关闭 975 102
//        sleepSecond(60,"下载完成");
//        cmdBy4G("am force-stop com.ss.android.ugc.aweme");
//
//
//
//
//
//
//
//
//        phoneAccountLogMapper.insert(
//                new PhoneAccountLog()
//                        .setAccountId(phoneEntity.getId())
//                        .setLogMsg("输口令看广告下载") /*5*/
//        );
//    }
//}